﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SpLocalizer.Common;
using Google.API.Translate;

namespace SpLocalizer.TranslationProvider
{
    public class GoogleTranslator : ITranslationProvider
    {
        private TranslateClient Client = null;

        public GoogleTranslator(string ApplicationKey)
        {
            
            this.Client = new TranslateClient(String.Empty);
            this.Client.ApiKey = ApplicationKey;
        }

        public BaseTranslationTask Translate(BaseTranslationTask task)
        {
            
            task.TranslatedText = this.Client.Translate(task.SourceText, task.FromLanguage.TwoLetterISOLanguageName,
                    task.ToLanguage.TwoLetterISOLanguageName, task.Format);

            return task;
            
        }

        
    }
}
